﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using YArchitech.DataModel;
using YArchitech.LIB;
using YArchitech.LIB.YJKControls;
using HYRevitCode.FormUtility;

namespace YArchitech.HVAC
{
	public partial class FrmLayFanCoilLoadCalculate : System.Windows.Forms.Form
	{
		public FrmLayFanCoilLoadCalculate()
		{
			this.InitializeComponent();
			List<KeyValuePair<Control, bool>> inputControlGroup = new List<KeyValuePair<Control, bool>>();
			this.m_thisManger = new ControlInfoManager(this, inputControlGroup, "{706337B0-F0FE-48DD-9B06-4FB53F157DBC}", null);
            //base.Icon = Resources.YArchitech;
			this.userSetting = new UserSetting();
			this.InitializeData();
		}

		private void btnOk_Click(object sender, EventArgs e)
		{
			base.DialogResult = DialogResult.OK;
		}

		private void btnCancel_Click(object sender, EventArgs e)
		{
			base.DialogResult = DialogResult.Cancel;
		}

		private void rdoCurrentProject_CheckedChanged(object sender, EventArgs e)
		{
			if (this.rdoCurrentProject.Checked)
			{
				this.fanCoilLayType = FanCoilLayType.CurrentProject;
				return;
			}
			if (this.rdoCurrentFloor.Checked)
			{
				this.fanCoilLayType = FanCoilLayType.CurrentFloor;
				return;
			}
			if (this.rdoFrameSelection.Checked)
			{
				this.fanCoilLayType = FanCoilLayType.FrameSelection;
			}
		}

		private void WriteData()
		{
			string text = "";
			if (this.rdoCurrentProject.Checked)
			{
				text = "0";
			}
			else if (this.rdoCurrentFloor.Checked)
			{
				text = "1";
			}
			else if (this.rdoFrameSelection.Checked)
			{
				text = "2";
			}
			this.userSetting.WriteValue("LayFanCoil", "LayType", text);
		}

		private void InitializeData()
		{
			string value = this.userSetting.GetValue("LayFanCoil", "LayType");
			if (value == "1")
			{
				this.rdoCurrentFloor.Checked = true;
				return;
			}
			if (value == "2")
			{
				this.rdoFrameSelection.Checked = true;
				return;
			}
			this.rdoCurrentProject.Checked = true;
		}

		private void FrmLayFanCoilLoadCalculate_FormClosed(object sender, FormClosedEventArgs e)
		{
			this.WriteData();
		}

		private void FrmLayFanCoilLoadCalculate_Load(object sender, EventArgs e)
		{
			if (this.m_thisManger != null && !this.m_thisManger.SetControlInfoToForm())
			{
				base.Location = new System.Drawing.Point(230, 170);
			}
		}

		private void FrmLayFanCoilLoadCalculate_FormClosing(object sender, FormClosingEventArgs e)
		{
			if (this.m_thisManger != null)
			{
				this.m_thisManger.GetControlInfoToXml();
			}
		}

		public FanCoilLayType fanCoilLayType;

		private UserSetting userSetting;

		private ControlInfoManager m_thisManger;
	}
}
